package userConsole.service;

import org.json.JSONException;
import org.json.JSONObject;
import userConsole.jdbc.BaseJDBC;
import userConsole.jdbc.UserJDBC;

import java.sql.Connection;
import java.sql.SQLException;

/**
 * @author Godv
 * @version 1.0
 */
public class InsertUserService {
    public JSONObject insertUser(String username, String password, String age) throws JSONException {
        JSONObject jsonObject = new JSONObject();
        try {
            new UserJDBC().insertUser(BaseJDBC.createConnection(), username, password, age);
            jsonObject.put("code", 200);
            jsonObject.put("msg", "新增用户成功");
        } catch (SQLException e) {
            e.printStackTrace();
            jsonObject.put("code", 306);
            jsonObject.put("msg", "系统繁忙，请稍候重试！");
        }
        return jsonObject;
    }
}
